package com.spring.boot.controller.root;

import com.spring.boot.entity.Users;
import com.spring.boot.entity.server.CommonResult;
import com.spring.boot.service.UsersService;
import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 后台用户控制器
 *
 * @author 刘骄阳
 * 2021-07-16 18:24
 */
@RestController
@RequestMapping("/root")
public class RootUsersController {

    @Resource
    UsersService usersService;

    /**
     * 后端管理登录
     *
     * @param users 用户对象
     * @return 数据
     */
    @PostAuthorize("hasRole('ROLE_管理员')")
//    @PostAuthorize("hasAnyAuthority('4')")
    @PostMapping("/rootLogin")
    public CommonResult rootLogin(Users users) {
        return usersService.rootLogin(users);
    }

}
